package com.markchu.web.structure.controller;

import com.markchu.modules.system.domain.BannerManage;
import com.markchu.modules.system.service.BannerManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController
@RequestMapping("/home")
public class CommonController {

    @Autowired
    private BannerManageService bannerManageService;

    @GetMapping("/common/banner")
    public String index(Model model,String pathName) {
        String bannerPath = "/upload_pic/images/20240105/d24a770c8f5e44b09224328acadccfa2.jpg";
        BannerManage bannerManage = bannerManageService.findByBannerLocation(pathName);
        if (!Objects.equals(bannerManage, null)){
            bannerPath = bannerManage.getBanner();
            return bannerPath;
        }else{
            return bannerPath;
        }
    }
}
